/**
 * @author Dave
 */
 
 /**
 * @class cmx.menu.MainMenu
 * @extends Ext.Toolbar
 * A specialized toolbar that imitates a desktop application's main menu
 * @constructor
 * Create a new MainMenu
 * @param {Object} config The config object
 */
cmx.menu.MainMenu = Ext.extend(Ext.Toolbar, {
	
	initComponent : function(){
        cmx.menu.MainMenu.superclass.initComponent.call(this);
        
    },
    
    // private
    onRender : function(ct, position){
        cmx.menu.MainMenu.superclass.onRender.call(this, ct, position);
        
        this.fileMenu = this.addButton(this.createFileMenu());
        this.editMenu = this.addButton(this.createEditMenu());
        this.viewMenu = this.addButton(this.createViewMenu());
        this.siteMenu = this.addButton(this.createSiteMenu());
        this.helpMenu = this.addButton(this.createHelpMenu());
    },
    
    createFileMenu : function(){
    	return {
    		xtype: 'tbbutton',
            text: 'File',
            menu: {
		        id: 'fileMenu',
		        items: [{
	                text: 'New',
	                menu: {        // <-- submenu by nested config object
	                    items: [{
                            text: 'Page'
                        },{
                            text: 'Template'                         
                        },{
			            	text: 'Site' 
			            }]
	                }
	            },{
	                text: 'Open',
            	},'-',{
	                text: 'Close'
	            },{
	                text: 'Close All'
	            },'-',{
	            	text: 'Save' 
	            },{
	            	text: 'Save As' 
	            },{
	            	text: 'Save All' 
	            }]
		    }
        }
    },
    
    createEditMenu : function(){
    	return {
    		xtype: 'tbbutton',
            text: 'Edit',
            menu: {
		        id: 'editMenu',
		        items: [{
	                text: 'Undo',
            	},{
	                text: 'Redo'
	            },'-',{
	                text: 'Cut',
            	},{
	                text: 'Copy'
	            },{
	                text: 'Paste'
	            },'-',{
	            	text: 'Delete' 
	            },{
	            	text: 'Select All' 
	            }]
    		}
		}
    },
    
    createViewMenu : function(){
    	return {
    		xtype: 'tbbutton',
            text: 'View',
            menu: {
		        id: 'viewMenu',
		        items: [{
	                text: 'Site Explorer',
	                checked: true,
                	checkHandler: function() {}
            	},{
	                text: 'File Explorer',
	                checked: false,
                	checkHandler: function() {}
	            },{
	                text: 'Properties',
	                checked: true,
                	checkHandler: function() {}
	            },{
	            	text: 'Permissions Manager',
	                checked: false,
                	checkHandler: function() {}
	            },{
	            	text: 'Start Page',
	                checked: true,
                	checkHandler: function() {}
	            }]
		    }
        }
    },
    
    createSiteMenu : function(){
    	return {
    		xtype: 'tbbutton',
            text: 'Site',
            menu: {
		        id: 'siteMenu',
		        items: [{
	                text: 'Publish',
            	},{
	                text: 'Publish To'
	            },{
	                text: 'Publish Settings'
	            }]
		    }
        }
    },
    
    createHelpMenu : function(){
    	return {
    		xtype: 'tbbutton',
            text: 'Help',
            menu: {
		        id: 'helpMenu',
		        items: [{
	                text: 'Help Contents',
            	},{
	                text: 'About'
	            }]
		    }
        }
    }
});